home *** CD-ROM | disk | FTP | other *** search
/ Mac Format 1995 June / MacFormat 25.iso / Shareware City / Developers / OutOfPhase1.1 Source / OutOfPhase Folder / SymbolList.c < prev    next >
Text File  |  1994-08-15  |  3KB  |  100 lines

  1. /* SymbolList.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #include "SymbolList.h"
  31. #include "TrashTracker.h"
  32. #include "Memory.h"
  33.  
  34.  
  35. struct SymbolListRec
  36.     {
  37.         struct SymbolRec*        First;
  38.         SymbolListRec*            Rest;
  39.     };
  40.  
  41.  
  42. /* cons operation for a symbol list */
  43. SymbolListRec*    SymbolListCons(struct SymbolRec* First, SymbolListRec* Rest,
  44.                                     struct TrashTrackRec* TrashTracker)
  45.     {
  46.         SymbolListRec*    NewConsCell;
  47.  
  48.         if (First != NIL)
  49.             {
  50.                 CheckPtrExistence(First);
  51.             }
  52.         if (Rest != NIL)
  53.             {
  54.                 CheckPtrExistence(Rest);
  55.             }
  56.  
  57.         NewConsCell = (SymbolListRec*)AllocTrackedBlock(sizeof(SymbolListRec),TrashTracker);
  58.         if (NewConsCell == NIL)
  59.             {
  60.                 return NIL;
  61.             }
  62.         SetTag(NewConsCell,"SymbolListRec");
  63.  
  64.         NewConsCell->First = First;
  65.         NewConsCell->Rest = Rest;
  66.  
  67.         return NewConsCell;
  68.     }
  69.  
  70.  
  71. /* get the first entry from the symbol list */
  72. struct SymbolRec*    GetFirstFromSymbolList(SymbolListRec* ListEntry)
  73.     {
  74.         CheckPtrExistence(ListEntry);
  75.         return ListEntry->First;
  76.     }
  77.  
  78.  
  79. /* get the rest list from the symbol list */
  80. SymbolListRec*    GetRestListFromSymbolList(SymbolListRec* ListEntry)
  81.     {
  82.         CheckPtrExistence(ListEntry);
  83.         return ListEntry->Rest;
  84.     }
  85.  
  86.  
  87. /* get the length of the symbol list */
  88. long                        GetSymbolListLength(SymbolListRec* ListEntry)
  89.     {
  90.         if (ListEntry == NIL)
  91.             {
  92.                 return 0;
  93.             }
  94.          else
  95.             {
  96.                 CheckPtrExistence(ListEntry);
  97.                 return 1 + GetSymbolListLength(ListEntry->Rest);
  98.             }
  99.     }
  100.